# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{4,5,6,7,8,9} )

inherit meson udev python-any-r1

DESCRIPTION="Library to configure gaming mice"
HOMEPAGE="https://github.com/libratbag/libratbag"
SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+systemd elogind doc test"
RESTRICT="!test? ( test )"

#REQUIRED_USE="${PYTHON_REQUIRED_USE}"

DEPEND="${PYTHON_DEPS}
	virtual/pkgconfig
	doc? ( app-doc/doxygen )
	virtual/libudev
	dev-lang/swig
	dev-libs/glib
	dev-libs/libevdev
	dev-python/python-evdev
	dev-libs/json-glib
	dev-libs/libunistring
"
RDEPEND="
	dev-libs/libevdev
	virtual/libudev
"

src_prepare() {
	default
	if use systemd && use elogind; then
		eerror "You can not have both systemd and elogind support, they are mutually exclusive !"
		die "Please unset one of them."
	fi
	sed '/default:/d' -i meson_options.txt || die
}

pkg_setup() {
        python-any-r1_pkg_setup
}


src_configure() {
	#python_setup 'python3'
	local emesonargs=(
		-Ddocumentation=$(usex doc true false)
		-Dtests=$(usex test true false)
		-Dudev-dir=$(get_udevdir)
		-Dsystemd=$(usex systemd true false)
		-Dlogind-provider=$(usex systemd systemd elogind)
	)
	meson_src_configure
}
